<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{:t('余额')}明细</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
	<style>
		.orderdetail{background:#f7f7f8;width: 94%;box-sizing:border-box;margin:0 10px;display:flex;flex-direction:column;}
		.orderdetail *{box-sizing:border-box;}
		.orderinfo{ width:100%;margin-top:5px;padding: 5px;background: #FFF;}
		.orderinfo .item{display:flex;width:100%;padding:10px 0;border-bottom:1px dashed #ededed;overflow:hidden}
		.orderinfo .item:last-child{ border-bottom: 0;}
		.orderinfo .item .t1{width:100px;flex-shrink:0}
		.orderinfo .item .t2{flex:1;text-align:right;}
		.orderinfo .item .red{color:red}
		.address{ display:flex;align-items:center;width: 100%; padding:10px 0; background: #FFF;color:#222}
		.address .img{width:45px;padding:0 10px}
		.address img{width:25px; height:25px;}
		.address .info{flex:1;display:flex;flex-direction:column;}
		.address .info .t1{ font-weight:bold}
		.product{width:100%; padding:5px;background: #FFF;margin: 5px 0px;}
		.product .content{display:flex;margin: 10px 0px;}
		.product .box{position:relative;width: 100%; padding:5px 0px;border-bottom: 1px #e5e5e5 dashed;position:relative}
		.product .content{display:flex;position:relative;}
		.product .box:last-child{ border-bottom: 0; }
		.product .content img{ width: 70px; height: 70px;}
		.product .content .detail{display:flex;flex-direction:column;margin-left:7px;flex:1}
		.product .content .detail .t1{height: 30px;line-height: 15px;color: #000;}
		.product .content .detail .t2{height: 23px;line-height: 23px;color: #999;overflow: hidden;font-size:13px;}
		.product .content .detail .t3{display:flex;height:15px;line-height:15px;color: #ff4246;}
		.product .content .detail .x1{ flex:1}
		.product .content .detail .x2{ width:50px;font-size:16px;text-align:right;margin-right:4px}
		.product .content .comment{position:absolute;top:32px;right:5px;border: 1px #ffc702 solid; border-radius:5px;background:#fff; color: #ffc702;  padding: 0 5px; height: 23px; line-height: 23px;}
	</style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card layui-col-md12">
          <div class="layui-card-header"><i class="fa fa-list"></i> {:t('余额')}明细
						{if input('param.isopen')==1}<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>{/if}</div>
          <div class="layui-card-body" pad15>
						<div class="layui-col-md2" style="padding-bottom:10px">
							<button class="layui-btn layui-btn-primary layuiadmin-btn-list" onclick="datadel(0)">删除</button>
							<button class="layui-btn layui-btn-primary layuiadmin-btn-list" data-form-export="{:url('moneylogexcel')}">导出EXCEL</button>
						</div>
						<div class="layui-form layui-col-md10 layui-form-search" style="width: 100%">
							
							<div class="layui-inline layuiadmin-input-useradmin">
								<label class="layui-form-label">{:t('会员')}ID</label>
								<div class="layui-input-inline">
									<input type="text" name="mid" autocomplete="off" class="layui-input" value="{$Request.param.mid}">
								</div>
							</div>
							<div class="layui-inline layuiadmin-input-useradmin">
								<label class="layui-form-label">手机号</label>
								<div class="layui-input-inline">
									<input type="text" name="tel" autocomplete="off" class="layui-input" value="{$Request.param.tel}">
								</div>
							</div>
							<div class="layui-inline layuiadmin-input-useradmin">
								<label class="layui-form-label">昵称</label>
								<div class="layui-input-inline">
									<input type="text" name="nickname" autocomplete="off" class="layui-input" value="">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">时间</label>
								<div class="layui-input-inline" style="width:180px">
									<input type="text" name="ctime" id="ctime" autocomplete="off" class="layui-input">
								</div>
							</div>
							
							
							<div class="layui-inline">
								<button class="layui-btn layuiadmin-btn-replys" lay-submit="" lay-filter="LAY-app-forumreply-search">
									<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
								</button>
							</div>
						</div>
						<div class="layui-col-md12" style="padding-bottom:10px;text-align: right">
							
						</div>
						<div class="layui-col-md12">
							<table id="tabledata" lay-filter="tabledata"></table>
						</div>
          </div>
        </div>
    </div>
  </div>
  <script id="detailtpl" type="text/html">
	  <div class="orderdetail">

		  <div class="address">
			  <div class="info">
				  <span class="t1">{{#  if(d.order.linkman){ }}{{d.order.linkman}}{{# } }} {{#  if(d.order.tel){ }}{{d.order.tel}}{{# } }}</span>
				  {{#  if(d.order.tablename){ }}
				  <span class="t2">桌号：{{d.order.tablename}}</span>
				  {{# } }}
				  
				  {{#  if(d.order.pickup_number){ }}
				  <span class="t2">取餐号：{{d.order.pickup_number}}</span>
				  {{# } }}
			  </div>
		  </div>

		  {{#  if(d.oglist.length > 0){ }}
		  <div class="product">
			  {{#  layui.each(d.oglist, function(index, item){ }}
			  <div class="content">
				  <div>
					  <img src="{{item.pic}}"/>
				  </div>
				  <div class="detail">
					  <span class="t1">{{item.name || item.proname}}</span>
					  <span class="" >{{item.ggname || ''}}</span>
					  <div class="t3"><span class="x1 flex1">￥{{item.sell_price}}</span><span class="x2">×{{item.num}}</span></div>
				  </div>
			  </div>
			  {{# }); }}
		  </div>
		  {{# } }}

		  {{#  if(d.order.message || d.order.remark || d.order.field1 || d.order.field2 || d.order.field3 || d.order.field4 || d.order.field5){ }}
		  <div class="orderinfo">
			  {{#  if(d.order.message){ }}
			  <div class="item">
				  <span class="t1">客户备注</span>
				  <span class="t2 red">{{d.order.message ? d.order.message : '无'}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.field1){ }}
			  <div class="item">
				  <span class="t1">{{d.order.field1data[0]}}</span>
				  <span class="t2 red">{{d.order.field1data[1]}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.field2){ }}
			  <div class="item">
				  <span class="t1">{{d.order.field2data[0]}}</span>
				  <span class="t2 red">{{d.order.field2data[1]}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.field3){ }}
			  <div class="item">
				  <span class="t1">{{d.order.field3data[0]}}</span>
				  <span class="t2 red">{{d.order.field3data[1]}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.field4){ }}
			  <div class="item">
				  <span class="t1">{{d.order.field4data[0]}}</span>
				  <span class="t2 red">{{d.order.field4data[1]}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.field5){ }}
			  <div class="item">
				  <span class="t1">{{d.order.field5data[0]}}</span>
				  <span class="t2 red">{{d.order.field5data[1]}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.remark){ }}
			  <div class="item">
				  <span class="t1">后台备注</span>
				  <span class="t2 red">{{d.order.remark ? d.order.remark : '无'}}</span>
			  </div>
			  {{# } }}
		  </div>
		  {{# } }}
		  <div class="orderinfo">
			  <div class="item">
				  <span class="t1">下单人</span>
				  <span class="t2"><img src="{{d.member.headimg}}" style="width:40px"/> {{d.member.nickname}} {{# if(d.member.realname){ }}[{{d.member.realname}} {{d.member.tel}}]{{#} }}</span>
			  </div>
			  <div class="item">
				  <span class="t1">{:t('会员')}ID</span>
				  <span class="t2">{{d.member.id}}</span>
			  </div>
		  </div>
		  <div class="orderinfo">
			  <div class="item">
				  <span class="t1">订单编号</span>
				  <span class="t2">{{d.order.ordernum}}</span>
			  </div>
			  <div class="item">
				  <span class="t1">下单时间</span>
				  <span class="t2">{{date('Y-m-d H:i:s',d.order.createtime)}}</span>
			  </div>
			  {{#  if(d.order.status>0 && d.order.paytime){ }}
			  <div class="item">
				  <span class="t1">支付时间</span>
				  <span class="t2">{{date('Y-m-d H:i:s',d.order.paytime)}}</span>
			  </div>
			  <div class="item">
				  <span class="t1">支付方式</span>
				  <span class="t2">{{d.order.paytype}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.status>1 && d.order.send_time){ }}
			  <div class="item">
				  <span class="t1">发货时间</span>
				  <span class="t2">{{date('Y-m-d H:i:s',d.order.send_time)}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.status==3 && d.order.collect_time){ }}
			  <div class="item">
				  <span class="t1">收货时间</span>
				  <span class="t2">{{date('Y-m-d H:i:s',d.order.collect_time)}}</span>
			  </div>
			  {{# } }}
		  </div>
		  <div class="orderinfo">
			  {{#  if(d.order.product_price){ }}
			  <div class="item">
				  <span class="t1">商品金额</span>
				  <span class="t2 red">¥{{d.order.product_price}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.tea_fee > 0){ }}
			  <div class="item">
				  <span class="t1">{{d.shopset.tea_fee_text}}</span>
				  <span class="t2">¥{{d.order.tea_fee}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.leveldk_money > 0){ }}
			  <div class="item">
				  <span class="t1">{:t('会员')}折扣</span>
				  <span class="t2 red">-¥{{d.order.leveldk_money}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.manjian_money > 0){ }}
			  <div class="item">
				  <span class="t1">满减活动</span>
				  <span class="t2 red">-¥{{d.order.manjian_money}}</span>
			  </div>
			  {{# } }}

			  {{#  if(d.order.coupon_money > 0){ }}
			  <div class="item">
				  <span class="t1">{:t('优惠券')}抵扣</span>
				  <span class="t2 red">-¥{{d.order.coupon_money}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.couponrecord){ }}
			  <div class="item">
				  <span class="t1">{:t('优惠券')}名称</span>
				  <span class="t2">{{d.couponrecord.couponname}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.scoredk_money > 0){ }}
			  <div class="item">
				  <span class="t1">{:t('积分')}抵扣</span>
				  <span class="t2 red">-¥{{d.order.scoredk_money}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.discount_money > 0){ }}
			  <div class="item">
				  <span class="t1">优惠</span>
				  <span class="t2 red">-¥{{d.order.discount_money}}</span>
			  </div>
			  {{# } }}
			  
			  <div class="item">
				  <span class="t1">实付款</span>
				  <span class="t2 red">¥{{d.order.totalprice}}</span>
			  </div>


			  <div class="item">
				  <span class="t1">订单状态</span>
				  {{#  if(d.order.status==0){ }}
				  <span class="t2" style="color:#ff8758">未付款 {{#  if(d.order.paytypeid=='4'){ }}线下支付{{# } }}</span>
				  {{# } }}
				  {{#  if(d.order.status==1 && d.order.paytypeid=='4'){ }}
				  <span class="t2" style="color:#008000">用餐中 线下支付</span>
				  {{# } }}
				  {{#  if(d.order.status==1 && d.order.paytypeid!='4'){ }}
				  <span class="t2" style="color:#008000">已支付</span>
				  {{# } }}
				  {{#  if(d.order.status==2){ }}
				  <span class="t2" style="color:#ff4246">已完成</span>
				  {{# } }}
				  {{#  if(d.order.status==3){ }}
				  <span class="t2" style="color:#999">已完成</span>
				  {{# } }}
				  {{#  if(d.order.status==4){ }}
				  <span class="t2" style="color:#bbb">已关闭</span>
				  {{# } }}
				  {{#  if(d.order.status==10){ }}
				  <span class="t2" style="color:#bbb">已退款</span>
				  {{# } }}
			  </div>
			  {{#  if(d.order.refund_status>0){ }}
			  <div class="item">
				  <span class="t1">退款状态</span>
				  {{#  if(d.order.refund_status==1){ }}
				  <span class="t2 red">审核中,¥{{d.order.refund_money}}</span>
				  {{# } }}
				  {{#  if(d.order.refund_status==2){ }}
				  <span class="t2 red">已退款,¥{{d.order.refund_money}}</span>
				  {{# } }}
				  {{#  if(d.order.refund_status==3){ }}
				  <span class="t2 red">已驳回,¥{{d.order.refund_money}}</span>
				  {{# } }}
			  </div>
			  {{#  if(d.order.refund_status==2){ }}
			  <div class="item">
				  <span class="t1">退款时间</span>
				  <span class="t2">{{date('Y-m-d H:i:s',d.order.refund_time)}}</span>
			  </div>
			  {{# } }}
			  {{# } }}
			  {{#  if(d.order.refund_checkremark){ }}
			  <div class="item">
				  <span class="t1">审核备注</span>
				  <span class="t2 red">{{d.order.refund_checkremark}}</span>
			  </div>
			  {{# } }}
			  {{#  if(d.order.realprice){ }}
			  <div class="item">
				  <span class="t1">实收款</span>
				  <span class="t2 red">¥{{d.order.realprice}}</span>
			  </div>
			  {{# } }}
		  </div>
		  {{#  if(d.comdata.length > 0){ }}
		  <div class="orderinfo">
			  <div class="item">
				  <span class="t1">一级{:t('佣金')}</span>
				  <span class="t2"><img src="{{d.comdata.parent1.headimg}}" style="width:30px"/> {{d.comdata.parent1.nickname}} <span style="color:#ff8758">{{d.comdata.parent1.money}}元 {{#  if(d.comdata.parent1.score){ }}+{{d.comdata.parent1.score}}{:t('积分')}{{# } }}</span></span>
			  </div>
			  <div class="item">
				  <span class="t1">二级{:t('佣金')}</span>
				  <span class="t2"><img src="{{d.comdata.parent2.headimg}}" style="width:30px"/> {{d.comdata.parent2.nickname}}  <span style="color:#ff8758">{{d.comdata.parent2.money}}元 {{#  if(d.comdata.parent2.score){ }}+{{d.comdata.parent2.score}}{:t('积分')}{{# } }}</span></span>
			  </div>
			  <div class="item">
				  <span class="t1">三级{:t('佣金')}</span>
				  <span class="t2"><img src="{{d.comdata.parent3.headimg}}" style="width:30px"/> {{d.comdata.parent3.nickname}}  <span style="color:#ff8758">{{d.comdata.parent3.money}}元  {{#  if(d.comdata.parent3.score){ }}+{{d.comdata.parent3.score}}{:t('积分')}{{# } }}</span></span>
			  </div>
		  </div>
		  {{# } }}
	  </div>
  </script>
	{include file="public/js"/}
	<script>
	layui.laydate.render({ 
		elem: '#ctime',
		trigger: 'click',
		range: '~', //或 range: '~' 来自定义分割字符
		type:'datetime'
	});
  var table = layui.table;
	var datawhere = {};
  //数据表
  var tableIns = table.render({
    elem: '#tabledata'
    ,url: "{$Request.url}" //数据接口
    ,page: true //开启分页
    ,cols: [[ //表头
			{type:"checkbox"},
      //{field: 'id', title: 'ID',sort:true,width:80},
      {field: 'mid', title: '{:t('会员')}ID',width:80},
      {field: 'nickname', title: '{:t('会员')}信息',templet:'<div>{{# if(d.nickname){ }}<img src="{{d.headimg}}" style="width:50px"> {{d.nickname}}{{# } }}</div>'},
      {field: 'money', title: '变更金额',sort:true,width:120,templet:function(d){ if(d.money>0)return '<span style="color:#03bc01;font-size:18px">+'+d.money+'</span>';else return '<span style="color:#000;font-size:16px">'+d.money+'</span>';}},
      {field: 'after', title: '变更后金额',sort:true,width:120},
      {field: 'createtime', title: '变更时间',sort:true,templet:function(d){ return date('Y-m-d H:i',d.createtime)}},
	  {field: 'paytype', title: '支付方式',width:120,templet:function(d){
		  if(d.paytype=='wxpay')return '微信';
		  else if(d.paytype=='alipay')return '支付宝';
		  else if(d.paytype=='cash')return '现金';
		  else if(d.paytype=='bank')return '银行卡';
		  else return '';
	  }},
	  
      {field: 'remark', title: '备注'},
		  
    
	  	{field: 'uid', title: '操作员',templet:function(d){
	  		var html = '';
	  		if(d.uid){
	  			html = d.un+"(操作员ID:"+d.uid+')';
	  		}
	  		return html;
	  	}},
      {field: 'op', title: '操作',templet:function(d){
				var html = '';
				if(d.rechargeid){
					html += '<button class="table-btn" onclick="openmax(\'{:url('Money/rechargelog')}&isopen=1&id='+d.rechargeid+'\')">充值明细</button>';
				}
				
					{if !getcustom('handle_auth') || ($auth_data=='all' || in_array('MoneylogDel',$auth_data))}
				html += '<button class="table-btn" onclick="datadel('+d.id+')">删除</button>';
					{/if}
				return html;
      },width:100}
    ]] 	,done:function(res, curr, count){
		  if(curr == 1){
			  $('#yuemoney').html('￥'+res.tongji.yue_money);
			  $('#givemoney').html('￥'+res.tongji.give_money);
		  }
	  }
  });
	//排序
	table.on('sort(tabledata)', function(obj){
		datawhere.field = obj.field;
		datawhere.order = obj.type;
		tableIns.reload({
			initSort: obj,
			where: datawhere
		});
	});
	//检索
	layui.form.on('submit(LAY-app-forumreply-search)', function(obj){
		var field = obj.field
		var olddatawhere = datawhere
		datawhere = field
		datawhere.field = olddatawhere.field
		datawhere.order = olddatawhere.order
		tableIns.reload({
			where: datawhere,
			page: {curr: 1}
		});
	})
	//删除
	function datadel(id){
		var ids = [];
		if(id==0){
			var checkStatus = table.checkStatus('tabledata')
			var checkData = checkStatus.data; //得到选中的数据
			if(checkData.length === 0){
				 return layer.msg('请选择数据');
			}
			var ids = [];
			for(var i=0;i<checkData.length;i++){
				ids.push(checkData[i]['id']);
			}
		}else{
			ids.push(id)
		}
		layer.confirm('确定要删除吗？删除后无法恢复！',{icon: 7, title:'操作确认'}, function(index){
			//do something
			layer.close(index);
			var index = layer.load();
			$.post("{:url('moneylogdel')}",{ids:ids},function(data){
				layer.close(index);
				dialog(data.msg,data.status);
				tableIns.reload()
			})
		});
	}
	
	</script>
	{include file="public/copyright"/}
</body>
</html>